home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-11 | 1.7 KB | 63 lines | [TEXT/MPS ] |
- //
- // GetFileVersion.c
- //
- // This code resource will be called as a Custom Version Compare
- // Procedure ( 'invc' ) from within the "File Compare by Procedure"
- // example.
- //
- // The function below simply reads the first 4 bytes of the 'vers' (1)
- // resource item of the currently selected file ( handle automatically
- // by the Installer ), and returns that value. If a 'vers' (1) resource
- // item cannot be found, then the value of the first four bytes of the
- // 'vers' (2) resource item is returned. If no 'vers' (1) or (2) resource
- // items are found, then the function returns 0.
- //
- // This by the way, is the default behavior of the Installer when
- // ascertaining the version number of a file, so this function when
- // implemented does not really do anything. But since this is a custom
- // code resource, we don't really know what you'll want to do with it
- // exactly. Customize this example as best fits the needs of your project.
- //
- //
- // Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
- //
-
-
- #ifndef __OSUtils__
- #include <OSUtils.h>
- #endif
-
- #ifndef __Errors__
- #include <Errors.h>
- #endif
-
- #ifndef __Resources__
- #include <Resources.h>
- #endif
-
- // NOTE: The name of this function 'GetFileVersion' should
- // match that specified in the -m option for the line in the
- // makefile that compiles this code resource.
- long GetFileVersion( void )
- {
-
- long theVersionNum = 0;
- long** longHandle;
-
- longHandle = (long**) Get1Resource( 'vers', 1 );
-
- if ( longHandle != NULL && ResError() == noErr )
- {
- theVersionNum = **longHandle;
- }
- else
- {
- longHandle = (long**) Get1Resource( 'vers', 2 );
-
- if ( longHandle != NULL && ResError() == noErr )
- theVersionNum = **longHandle;
- }
-
- return theVersionNum;
- }
-